/*
 * Copyright (C) Francisco Morero Peyrona. All rights reserved.
 *
 * This software is published under the terms of Open Source 
 * License version 1.1, a copy of which has been included with this
 * distribution in the License.txt file.  
 */
 
package jdbcmanager.tree;

import java.awt.*;
import javax.swing.*;

import jdbcmanager.dbtools.*;

/**
 * Shows a dialog with following information about selected catalog:
 * Catalog's name and 2 list boxes: one with the schemas and 
 * the other with the table types.
 * 
 * @author Francisco Morero Peyrona
 */
final class Info4Catalog extends JPanel 
{  
   Info4Catalog( String sCatalog )
   {   
      // Schemas ------------------------------------------- 
      
      String[] asSchema    = DbUtil.getAgentDBMS().getAgentMetaData().getSchemas();
      String   sSchemaTerm = DbUtil.getAgentDBMS().getAgentMetaData().getSchemaTerm();
      
      if( asSchema.length == 0 )
         asSchema = new String[] { sSchemaTerm +"s are not supported" };
      
      JList lstSchemas = new JList( asSchema );
            lstSchemas.setSelectedIndex( 0 );
      
      JPanel pnlSchemas = new JPanel( new BorderLayout() );
             pnlSchemas.setBorder( BorderFactory.createEmptyBorder( 9,0,9,9 ) );
             pnlSchemas.add( new JLabel( sSchemaTerm +'s' ), BorderLayout.NORTH );
             pnlSchemas.add( new JScrollPane( lstSchemas ), BorderLayout.CENTER );
      
      // Table Types -------------------------------------

      String[] asTblType = DbUtil.getAgentDBMS().getAgentMetaData().getTableTypes();

      if( asTblType.length == 0 )
         asTblType = new String[] { "Table Types are not supported" };
      
      JList lstTableTypes = new JList( asTblType );
            lstTableTypes.setSelectedIndex( 0 );
      
      JPanel pnlTblTypes = new JPanel( new BorderLayout() );
             pnlTblTypes.setBorder( BorderFactory.createEmptyBorder( 9,9,9,0 ) );
             pnlTblTypes.add( new JLabel( "Table Types" ), BorderLayout.NORTH );
             pnlTblTypes.add( new JScrollPane( lstTableTypes ), BorderLayout.CENTER );

      // All together -------------------------------------
          
      setLayout( new BorderLayout() );
      setBorder( BorderFactory.createEmptyBorder( 9,9,9,9 ) );

      add( new JLabel( "Name = ["+ sCatalog +']' ), BorderLayout.NORTH );
      add( pnlSchemas , BorderLayout.WEST );
      add( pnlTblTypes, BorderLayout.EAST );
   }
}
